import { ref } from "vue"
import { defineStore } from "pinia"
import { ApplicationContext } from "@/core/application/application-context"
import { aboutApplicationInfo } from "@/application/about"
import { themeSettingApplicationInfo } from "@/application/theme-setting"
import { chatApplicationInfo } from "@/application/chat"
import { musicApplicationInfo } from "@/application/music"
import { windowManagerApplicationInfo } from "@/application/window-manager"

const defaultApplicationContext = new ApplicationContext()

defaultApplicationContext.register(aboutApplicationInfo)
defaultApplicationContext.register(themeSettingApplicationInfo)
defaultApplicationContext.register(chatApplicationInfo)
defaultApplicationContext.register(musicApplicationInfo)
defaultApplicationContext.register(windowManagerApplicationInfo)

export const useApplicationStore = defineStore(
  "application",
  () => {
    const applicationsContext = ref<ApplicationContext>(defaultApplicationContext)

    return {
      applicationsContext
    }
  },
  {
    persist: ["applicationsContext"]
  }
)
